package com.demo2do.fms.queue.dao;

import com.demo2do.core.persistence.annotation.Dao;
import com.demo2do.core.persistence.annotation.Query;
import com.demo2do.core.persistence.annotation.Variable;
import com.demo2do.fms.entity.vehicle.source.VehicleSource;

/**
 *
 * @author Ark
 *
 */
@Dao("hibernate")
public interface VehicleSourceDao {

    /**
     * @param brand
     * @return
     */
    @Query("FROM VehicleSource WHERE tractorBrandCode = :brand AND code IS NOT NULL AND disabled = true ORDER BY lastModifyTime DESC")
    public VehicleSource getOldVehicleByBrand(@Variable("brand") String brand);
    
    /**
     * @param brand
     * @return
     */
    @Query("FROM VehicleSource WHERE tractorBrandCode = :brand AND disabled = false")
    public VehicleSource getByBrand(@Variable("brand") String brand);
    
    /**
     * @param tractorId
     * @return
     */
    @Query("FROM VehicleSource WHERE disabled = false AND tractorId = :tractorId")
    public VehicleSource loadByTractor(@Variable("tractorId") Long tractorId);
    
    /**
     * @param trailerId
     * @return
     */
    @Query("FROM VehicleSource WHERE disabled = false AND trailerId = :trailerId")
    public VehicleSource loadByTrailer(@Variable("trailerId") Long trailerId);
    
}
